package demo.helloworld.service;

import act.db.ebean.EbeanDao;
import demo.helloworld.model.Comments;

import javax.inject.Inject;
import java.util.List;

/**
 * Created by vilen on 2017/2/28.
 */
public class CommentsService {
    @Inject
    private EbeanDao<Integer, Comments> dao;
    public List<Comments> listAllComments() {
        return dao.findAllAsList();
    }

    public List<Comments> listRecentComments(int limit) {
        // setMaxRow 和 subList() sql 不一样
        return dao.ebean().find(Comments.class).setMaxRows(limit).findList();
    }
}
